﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Entities;

namespace SportsStore.WebUI.Models
{
    public class AdminIndexViewModel
    {
        public int CategoryId { get; set; }
        public IEnumerable<Product> Products { get; set; } 

        public IEnumerable<Category> Categories { get; set; } 
        public IEnumerable<SelectListItem> GetCategoryList()
        {
            //var categoryList = Categories.OrderBy(c=>c.Ranking).Select(a => new SelectListItem { Text = a.Name, Value = a.Id.ToString() });
            var categoryList = Categories.OrderBy(c => c.Ranking);
            List<SelectListItem> dropDownListItems = new List<SelectListItem>();
            foreach( var category in categoryList)
                dropDownListItems.Add(new SelectListItem{Text=category.Name,Value = category.Id.ToString()});
            dropDownListItems.Insert(0, new SelectListItem {Text = "所有产品", Value = 0.ToString()});
            return dropDownListItems;
        }
    }
}